#include "MG90.h"
#include "tim.h"

void mg90_init(void)
{
	MX_TIM9_Init();
	HAL_TIM_PWM_Start(&htim9,TIM_CHANNEL_1);
	__HAL_TIM_SET_COMPARE(&htim9,TIM_CHANNEL_1,150);
    HAL_TIM_PWM_Start(&htim9,TIM_CHANNEL_2);
	__HAL_TIM_SET_COMPARE(&htim9,TIM_CHANNEL_2,150);
}
/***********************���1****************************************************/
void action1_m(void)//����150
{
	    __HAL_TIM_SET_COMPARE(&htim9,TIM_CHANNEL_1,150);
		//HAL_Delay(1000);
}

void action1_r(void)//����150
{

    	__HAL_TIM_SET_COMPARE(&htim9,TIM_CHANNEL_1,50);//��180
		//HAL_Delay(1000);	
}
void action1_l(void)//����150
{
	
		__HAL_TIM_SET_COMPARE(&htim9,TIM_CHANNEL_1,250);//��180
		//HAL_Delay(1000);
}
/***********************���2****************************************************/
void action2_m(void)//����150
{
	    __HAL_TIM_SET_COMPARE(&htim9,TIM_CHANNEL_2,150);
		//HAL_Delay(1000);
}

void action2_r(void)//����150
{

    	__HAL_TIM_SET_COMPARE(&htim9,TIM_CHANNEL_2,50);//��180
		//HAL_Delay(1000);	
}
void action2_l(void)//����150
{
	
		__HAL_TIM_SET_COMPARE(&htim9,TIM_CHANNEL_2,250);//��180
		//HAL_Delay(1000);
}

void huizhong(void)
{
	action1_m();
	action2_m();
	HAL_Delay(1000);
}

void zhuaqu(void)
{
	action1_l();
	action2_r();
	HAL_Delay(1000);
}
